home *** CD-ROM | disk | FTP | other *** search
/ Kit PC World De Ampliacion De Windows 95 / Kit PC World de ampliacion de Windows 95.iso / internet / sweeper / samples / olecon~1 / controls / autosa~1 / rectan~1.cpp < prev    next >
Text File  |  1995-11-25  |  7KB  |  312 lines

  1. //=--------------------------------------------------------------------------=
  2. // RectangleObj.Cpp
  3. //=--------------------------------------------------------------------------=
  4. // Copyright  1995  Microsoft Corporation.  All Rights Reserved.
  5. //
  6. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 
  7. // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO 
  8. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 
  9. // PARTICULAR PURPOSE.
  10. //=--------------------------------------------------------------------------=
  11. //
  12. // the Rectangle object
  13. //
  14. //
  15. #include "IPServer.H"
  16.  
  17. #include "LocalObj.H"
  18. #include "RectangleObj.H"
  19.  
  20.  
  21. // for ASSERT and FAIL
  22. //
  23. SZTHISFILE
  24.  
  25. //=--------------------------------------------------------------------------=
  26. // CRectangle::Create
  27. //=--------------------------------------------------------------------------=
  28. // creates a new Rectangle object.
  29. //
  30. // Parameters:
  31. //    IUnknown *        - [in] controlling unkonwn
  32. //
  33. // Output:
  34. //    IUnknown *        - new object.
  35. //
  36. // Notes:
  37. //
  38. IUnknown *CRectangle::Create
  39. (
  40.     IUnknown *pUnkOuter
  41. )
  42. {
  43.     // make sure we return the private unknown so that we support aggegation
  44.     // correctly!
  45.     //
  46.     CRectangle *pNew = new CRectangle(pUnkOuter);
  47.     return pNew->PrivateUnknown();
  48. }
  49.  
  50. //=--------------------------------------------------------------------------=
  51. // CRectangle::CRectangle
  52. //=--------------------------------------------------------------------------=
  53. // create the object and initialize the refcount
  54. //
  55. // Parameters:
  56. //    IUnknown *    - [in] controlling unknown
  57. //
  58. // Notes:
  59. //
  60. #pragma warning(disable:4355)  // using 'this' in constructor
  61. CRectangle::CRectangle
  62. (
  63.     IUnknown *pUnkOuter
  64. )
  65. : CAutomationObject(pUnkOuter, OBJECT_TYPE_OBJRECTANGLE, (void *)this)
  66. {
  67.  
  68.     // TODO: initialize anything here
  69.     //
  70.     memset(&m_rect, 0, sizeof(m_rect));
  71. }
  72. #pragma warning(default:4355)  // using 'this' in constructor
  73.  
  74. //=--------------------------------------------------------------------------=
  75. // CRectangle::CRectangle
  76. //=--------------------------------------------------------------------------=
  77. // "We all labour against our own cure, for death is the cure of all diseases"
  78. //    - Sir Thomas Browne (1605 - 82)
  79. //
  80. // Notes:
  81. //
  82. CRectangle::~CRectangle ()
  83. {
  84.     // TODO: clean up anything here.
  85. }
  86.  
  87. //=--------------------------------------------------------------------------=
  88. // CRectangle::InternalQueryInterface
  89. //=--------------------------------------------------------------------------=
  90. // the controlling unknown will call this for us in the case where they're
  91. // looking for a specific interface.
  92. //
  93. // Parameters:
  94. //    REFIID        - [in]  interface they want
  95. //    void **       - [out] where they want to put the resulting object ptr.
  96. //
  97. // Output:
  98. //    HRESULT       - S_OK, E_NOINTERFACE
  99. //
  100. // Notes:
  101. //
  102. HRESULT CRectangle::InternalQueryInterface
  103. (
  104.     REFIID riid,
  105.     void **ppvObjOut
  106. )
  107. {
  108.     CHECK_POINTER(ppvObjOut);
  109.  
  110.     // we support IRectangle and ISupportErrorInfo
  111.     //
  112.     if (DO_GUIDS_MATCH(riid, IID_IRectangle)) {
  113.         *ppvObjOut = (void *)(IRectangle *)this;
  114.         AddRef();
  115.         return S_OK;
  116.     } else if (DO_GUIDS_MATCH(riid, IID_ISupportErrorInfo)) {
  117.         *ppvObjOut = (void *)(ISupportErrorInfo *)this;
  118.         AddRef();
  119.         return S_OK;
  120.     }
  121.  
  122.     // call the super-class version and see if it can oblige.
  123.     //
  124.     return CAutomationObject::InternalQueryInterface(riid, ppvObjOut);
  125. }
  126.  
  127.  
  128.  
  129. // TODO: implement your interface methods and property exchange functions
  130. //       here.
  131.  
  132.  
  133. //=--------------------------------------------------------------------------=
  134. // CRectangle::get_Bottom    [IRectangle]
  135. //=--------------------------------------------------------------------------=
  136. // returns current value of bottom
  137. //
  138. // Parameters:
  139. //    long *        - [out] duh.
  140. //
  141. // Output:
  142. //    HRESULT
  143. //
  144. // Notes:
  145. //
  146. STDMETHODIMP CRectangle::get_Bottom
  147. (
  148.     long *plBottom
  149. )
  150. {
  151.     CHECK_POINTER(plBottom);
  152.  
  153.     *plBottom = m_rect.bottom;
  154.     return S_OK;
  155. }
  156.  
  157. //=--------------------------------------------------------------------------=
  158. // CRectangle::put_Bottom    [IRectangle]
  159. //=--------------------------------------------------------------------------=
  160. // sets bottom
  161. //
  162. // Parameters:
  163. //    long            - [in] duh.
  164. //
  165. // Output:
  166. //    HRESULT
  167. //
  168. // Notes:
  169. //
  170. STDMETHODIMP CRectangle::put_Bottom
  171. (
  172.     long lBottom
  173. )
  174. {
  175.     m_rect.bottom = lBottom;
  176.     return S_OK;
  177. }
  178.  
  179. //=--------------------------------------------------------------------------=
  180. // CRectangle::get_Left    [IRectangle]
  181. //=--------------------------------------------------------------------------=
  182. //
  183. // Parameters:
  184. //    long *        - [out] duh.
  185. //
  186. // Output:
  187. //    HRESULT
  188. //
  189. // Notes:
  190. //
  191. STDMETHODIMP CRectangle::get_Left
  192. (
  193.     long *plLeft
  194. )
  195. {
  196.     CHECK_POINTER(plLeft);
  197.  
  198.     *plLeft = m_rect.left;
  199.     return S_OK;
  200. }
  201.  
  202. //=--------------------------------------------------------------------------=
  203. // CRectangle::put_Left    [IRectangle]
  204. //=--------------------------------------------------------------------------=
  205. //
  206. // Parameters:
  207. //    long            - [in] duh.
  208. //
  209. // Output:
  210. //    HRESULT
  211. //
  212. // Notes:
  213. //
  214. STDMETHODIMP CRectangle::put_Left
  215. (
  216.     long lLeft
  217. )
  218. {
  219.     m_rect.left = lLeft;
  220.     return S_OK;
  221. }
  222.  
  223. //=--------------------------------------------------------------------------=
  224. // CRectangle::get_Right    [IRectangle]
  225. //=--------------------------------------------------------------------------=
  226. //
  227. // Parameters:
  228. //    long *        - [out] duh.
  229. //
  230. // Output:
  231. //    HRESULT
  232. //
  233. // Notes:
  234. //
  235. STDMETHODIMP CRectangle::get_Right
  236. (
  237.     long *plRight
  238. )
  239. {
  240.     CHECK_POINTER(plRight);
  241.  
  242.     *plRight = m_rect.right;
  243.     return S_OK;
  244. }
  245.  
  246. //=--------------------------------------------------------------------------=
  247. // CRectangle::put_Right    [IRectangle]
  248. //=--------------------------------------------------------------------------=
  249. //
  250. // Parameters:
  251. //    long            - [in] duh.
  252. //
  253. // Output:
  254. //    HRESULT
  255. //
  256. // Notes:
  257. //
  258. STDMETHODIMP CRectangle::put_Right
  259. (
  260.     long lRight
  261. )
  262. {
  263.     m_rect.right = lRight;
  264.     return S_OK;
  265. }
  266.  
  267. //=--------------------------------------------------------------------------=
  268. // CRectangle::get_Top    [IRectangle]
  269. //=--------------------------------------------------------------------------=
  270. //
  271. // Parameters:
  272. //    long *        - [out] duh.
  273. //
  274. // Output:
  275. //    HRESULT
  276. //
  277. // Notes:
  278. //
  279. STDMETHODIMP CRectangle::get_Top
  280. (
  281.     long *plTop
  282. )
  283. {
  284.     CHECK_POINTER(plTop);
  285.  
  286.     *plTop = m_rect.top;
  287.     return S_OK;
  288. }
  289.  
  290. //=--------------------------------------------------------------------------=
  291. // CRectangle::put_Top    [IRectangle]
  292. //=--------------------------------------------------------------------------=
  293. //
  294. // Parameters:
  295. //    long            - [in] duh.
  296. //
  297. // Output:
  298. //    HRESULT
  299. //
  300. // Notes:
  301. //
  302. STDMETHODIMP CRectangle::put_Top
  303. (
  304.     long lTop
  305. )
  306. {
  307.     m_rect.top = lTop;
  308.     return S_OK;
  309. }
  310.  
  311.  
  312.